home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Macintosh Sample Code / SC.013.OOPTESample / UDocument.inc1.p < prev    next >
Encoding:
Text File  |  1989-09-30  |  9.4 KB  |  445 lines  |  [TEXT/MPS ]

  1. {---------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple TextEdit Sample Application
  6. #
  7. #    OOPTESample
  8. #
  9. #    UDocument.inc1.p        -    Pascal Source
  10. #
  11. #    Copyright © 1988, 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Version:        
  15. #                    1.10                    10/89
  16. #                    1.00                    04/89
  17. #
  18. #    Components:     
  19. #                    BuildOOPTESample        October 1, 1989
  20. #                    MOOPTESample.p            October 1, 1989
  21. #                    OOPTESample.make        October 1, 1989
  22. #                    TECommon.h                October 1, 1989
  23. #                    TESampleGlue.a            October 1, 1989
  24. #                    TESample.r                October 1, 1989
  25. #                    UApplication.p            October 1, 1989
  26. #                    UApplication.inc1.p        October 1, 1989
  27. #                    UDocument.p                October 1, 1989
  28. #                    UDocument.inc1.p        October 1, 1989
  29. #                    UTEDocument.p            October 1, 1989
  30. #                    UTEDocument.inc1.p        October 1, 1989
  31. #                    UTESample.p                October 1, 1989
  32. #                    UTESample.inc1.p        October 1, 1989
  33. #
  34. ---------------------------------------------------------------------}
  35.  
  36. (********************************************************************************************)
  37. (*        T D o c u m e n t                                                                    *)
  38. (********************************************************************************************)
  39.  
  40. {$S Initialize}
  41. {-----------------------------------+
  42. |    IDocument                        |
  43. +-----------------------------------}
  44. PROCEDURE TDocument.IDocument(resID: integer);
  45. VAR
  46.     aWindow : WindowPtr;
  47. BEGIN
  48.     aWindow := GetNewWindow(resID,NIL,WindowPtr(-1));
  49.     fDocWindow := aWindow;
  50.     SetPort(aWindow);
  51. END;
  52.  
  53. {$S Main}
  54. {-----------------------------------+
  55. |    Free                            |
  56. +-----------------------------------}
  57. PROCEDURE TDocument.Free; OVERRIDE;
  58. BEGIN
  59.     DisposeWindow(fDocWindow);
  60.     INHERITED Free;
  61. END;
  62.  
  63. {$S Main}
  64. {-----------------------------------+
  65. |    DoZoom                            |
  66. +-----------------------------------}
  67. PROCEDURE TDocument.DoZoom(partCode: integer);
  68. BEGIN
  69. END;
  70.  
  71. {$S Main}
  72. {-----------------------------------+
  73. |    DoGrow                            |
  74. +-----------------------------------}
  75. PROCEDURE TDocument.DoGrow(theEvent: EventRecord);
  76. BEGIN
  77. END;
  78.  
  79. {$S Main}
  80. {-----------------------------------+
  81. |    DoContent                        |
  82. +-----------------------------------}
  83. PROCEDURE TDocument.DoContent(theEvent: EventRecord);
  84. BEGIN
  85. END;
  86.  
  87. {$S Main}
  88. {-----------------------------------+
  89. |    DoKeyDown                        |
  90. +-----------------------------------}
  91. PROCEDURE TDocument.DoKeyDown(theEvent: EventRecord);
  92. BEGIN
  93. END;
  94.  
  95. {$S Main}
  96. {-----------------------------------+
  97. |    DoActivate                        |
  98. +-----------------------------------}
  99. PROCEDURE TDocument.DoActivate(becomingActive: Boolean);
  100. BEGIN
  101. END;
  102.  
  103. {$S Main}
  104. {-----------------------------------+
  105. |    DoUpdate                        |
  106. +-----------------------------------}
  107. PROCEDURE TDocument.DoUpdate;
  108. BEGIN
  109. END;
  110.  
  111. {$S Main}
  112. {-----------------------------------+
  113. |    DoOpen                            |
  114. +-----------------------------------}
  115. PROCEDURE TDocument.DoOpen;
  116. BEGIN
  117. END;
  118.  
  119. {$S Main}
  120. {-----------------------------------+
  121. |    DoClose                            |
  122. +-----------------------------------}
  123. PROCEDURE TDocument.DoClose;    { By default, we just delete ourself. }
  124. BEGIN
  125.     SELF.Free;
  126. END;
  127.  
  128. {$S Main}
  129. {-----------------------------------+
  130. |    DoSave                            |
  131. +-----------------------------------}
  132. PROCEDURE TDocument.DoSave;
  133. BEGIN
  134. END;
  135.  
  136. {$S Main}
  137. {-----------------------------------+
  138. |    DoSaveAs                        |
  139. +-----------------------------------}
  140. PROCEDURE TDocument.DoSaveAs;
  141. BEGIN
  142. END;
  143.  
  144. {$S Main}
  145. {-----------------------------------+
  146. |    DoRevert                        |
  147. +-----------------------------------}
  148. PROCEDURE TDocument.DoRevert;
  149. BEGIN
  150. END;
  151.  
  152. {$S Main}
  153. {-----------------------------------+
  154. |    DoPrint                            |
  155. +-----------------------------------}
  156. PROCEDURE TDocument.DoPrint;
  157. BEGIN
  158. END;
  159.  
  160. {$S Main}
  161. {-----------------------------------+
  162. |    DoUndo                            |
  163. +-----------------------------------}
  164. PROCEDURE TDocument.DoUndo;
  165. BEGIN
  166. END;
  167.  
  168. {$S Main}
  169. {-----------------------------------+
  170. |    DoCut                            |
  171. +-----------------------------------}
  172. PROCEDURE TDocument.DoCut;
  173. BEGIN
  174. END;
  175.  
  176. {$S Main}
  177. {-----------------------------------+
  178. |    DoCopy                            |
  179. +-----------------------------------}
  180. PROCEDURE TDocument.DoCopy;
  181. BEGIN
  182. END;
  183.  
  184. {$S Main}
  185. {-----------------------------------+
  186. |    DoPaste                            |
  187. +-----------------------------------}
  188. PROCEDURE TDocument.DoPaste;
  189. BEGIN
  190. END;
  191.  
  192. {$S Main}
  193. {-----------------------------------+
  194. |    DoClear                            |
  195. +-----------------------------------}
  196. PROCEDURE TDocument.DoClear;
  197. BEGIN
  198. END;
  199.  
  200. {$S Main}
  201. {-----------------------------------+
  202. |    DoSelectAll                        |
  203. +-----------------------------------}
  204. PROCEDURE TDocument.DoSelectAll;
  205. BEGIN
  206. END;
  207.  
  208. {$S Main}
  209. {-----------------------------------+
  210. |    DoIdle                            |
  211. +-----------------------------------}
  212. PROCEDURE TDocument.DoIdle;
  213. BEGIN
  214. END;
  215.  
  216. {$S Main}
  217. {-----------------------------------+
  218. |    CalcIdle                        |
  219. +-----------------------------------}
  220. FUNCTION TDocument.CalcIdle:Longint;
  221. BEGIN
  222.     CalcIdle := $7FFFFFFF;
  223. END;
  224.  
  225. {$S Main}
  226. {-----------------------------------+
  227. |    AdjustCursor                    |
  228. +-----------------------------------}
  229. PROCEDURE TDocument.AdjustCursor(where: Point); { where is in local coords. }
  230. BEGIN
  231. END;
  232.  
  233. {$S Main}
  234. {-----------------------------------+
  235. |    HaveUndo                        |
  236. +-----------------------------------}
  237. FUNCTION TDocument.HaveUndo: Boolean;
  238. BEGIN
  239.     HaveUndo := FALSE;
  240. END;
  241.  
  242. {$S Main}
  243. {-----------------------------------+
  244. |    HaveSelection                    |
  245. +-----------------------------------}
  246. FUNCTION TDocument.HaveSelection: Boolean;
  247. BEGIN
  248.     HaveSelection := FALSE;
  249. END;
  250.  
  251. {$S Main}
  252. {-----------------------------------+
  253. |    HavePaste                        |
  254. +-----------------------------------}
  255. FUNCTION TDocument.HavePaste: Boolean;
  256. BEGIN
  257.     HavePaste := FALSE;
  258. END;
  259.  
  260. {$S Main}
  261. {-----------------------------------+
  262. |    CanClose                        |
  263. +-----------------------------------}
  264. FUNCTION TDocument.CanClose: Boolean;
  265. BEGIN
  266.     CanClose := TRUE;
  267. END;
  268.  
  269. {$S Main}
  270. {-----------------------------------+
  271. |    CanSave                            |
  272. +-----------------------------------}
  273. FUNCTION TDocument.CanSave: Boolean;
  274. BEGIN
  275.     CanSave := FALSE;
  276. END;
  277.  
  278. {$S Main}
  279. {-----------------------------------+
  280. |    CanSaveAs                        |
  281. +-----------------------------------}
  282. FUNCTION TDocument.CanSaveAs: Boolean;
  283. BEGIN
  284.     CanSaveAs := TRUE;
  285. END;
  286.  
  287. {$S Main}
  288. {-----------------------------------+
  289. |    CanRevert                        |
  290. +-----------------------------------}
  291. FUNCTION TDocument.CanRevert: Boolean;
  292. BEGIN
  293.     CanRevert := FALSE;
  294. END;
  295.  
  296. {$S Main}
  297. {-----------------------------------+
  298. |    CanPrint                        |
  299. +-----------------------------------}
  300. FUNCTION TDocument.CanPrint: Boolean;
  301. BEGIN
  302.     CanPrint := FALSE;
  303. END;
  304.  
  305. {$S Main}
  306. {-----------------------------------+
  307. |    GetDocWindow                    |
  308. +-----------------------------------}
  309. FUNCTION TDocument.GetDocWindow: WindowPtr;
  310. BEGIN
  311.     GetDocWindow := fDocWindow;
  312. END;
  313.  
  314. (********************************************************************************************)
  315. (*        T D o c u m e n t L i n k                                                            *)
  316. (********************************************************************************************)
  317.  
  318. {$S Initialize}
  319. {-----------------------------------+
  320. |    IDocumentLink                    |
  321. +-----------------------------------}
  322. PROCEDURE TDocumentLink.IDocumentLink(n:TDocumentLink; v:TDocument);
  323. BEGIN
  324.     fNext := n;
  325.     fDoc := v;
  326. END;
  327.  
  328. {$S Main}
  329. {-----------------------------------+
  330. |    GetNext                            |
  331. +-----------------------------------}
  332. FUNCTION TDocumentLink.GetNext:TDocumentLink;
  333. BEGIN
  334.     GetNext := fNext;
  335. END;
  336.  
  337. {$S Main}
  338. {-----------------------------------+
  339. |    GetDoc                            |
  340. +-----------------------------------}
  341. FUNCTION TDocumentLink.GetDoc: TDocument;
  342. BEGIN
  343.     GetDoc := fDoc;
  344. END;
  345.  
  346. {$S Main}
  347. {-----------------------------------+
  348. |    SetNext                            |
  349. +-----------------------------------}
  350. PROCEDURE TDocumentLink.SetNext(aLink:TDocumentLink);
  351. BEGIN
  352.     fNext := aLink;
  353. END;
  354.  
  355. {$S Main}
  356. {-----------------------------------+
  357. |    SetDoc                            |
  358. +-----------------------------------}
  359. PROCEDURE TDocumentLink.SetDoc(aDoc:TDocument);
  360. BEGIN
  361.     fDoc := aDoc;
  362. END;
  363.  
  364. (********************************************************************************************)
  365. (*        T D o c u m e n t L i s t                                                            *)
  366. (********************************************************************************************)
  367.  
  368. {$S Initialize}
  369. {-----------------------------------+
  370. |    IDocumentList                    |
  371. +-----------------------------------}
  372. PROCEDURE TDocumentList.IDocumentList;
  373. BEGIN
  374.     fDocList := NIL;
  375.     fNumDocs := 0;
  376. END;
  377.  
  378. {$S Initialize}
  379. {-----------------------------------+
  380. |    AddDoc                            |
  381. +-----------------------------------}
  382. PROCEDURE TDocumentList.AddDoc(doc:TDocument);
  383. VAR
  384.     temp: TDocumentLink;
  385. BEGIN
  386.     NEW(temp);
  387.     temp.IDocumentLink(fDocList,doc);
  388.     fDocList := temp;
  389.     fNumDocs := fNumDocs+1;
  390. END;
  391.  
  392. {$S Main}
  393. {-----------------------------------+
  394. |    RemoveDoc                        |
  395. +-----------------------------------}
  396. PROCEDURE TDocumentList.RemoveDoc(doc:TDocument);
  397. VAR
  398.     temp, last: TDocumentLink;
  399. BEGIN
  400.     last := NIL;
  401.     temp := fDocList;
  402.     WHILE (temp <> NIL) DO BEGIN
  403.         IF (temp.GetDoc = doc) THEN BEGIN
  404.             IF (last = NIL) THEN BEGIN
  405.                 fDocList := temp.GetNext;
  406.             END ELSE BEGIN
  407.                 last.SetNext(temp.GetNext);
  408.             END;
  409.             temp.Free;
  410.             fNumDocs := fNumDocs - 1;
  411.             EXIT(RemoveDoc);
  412.         END ELSE BEGIN
  413.             last := temp;
  414.         END;
  415.         temp := temp.GetNext;
  416.     END;
  417. END;
  418.  
  419. {$S Main}
  420. {-----------------------------------+
  421. |    FindDoc                            |
  422. +-----------------------------------}
  423. FUNCTION TDocumentList.FindDoc(window:WindowPtr): TDocument;
  424. VAR
  425.     temp: TDocumentLink;
  426.     tDoc: TDocument;
  427. BEGIN
  428.     FindDoc := NIL;
  429.     temp := fDocList;
  430.     WHILE (temp <> NIL) DO BEGIN
  431.         tDoc := temp.Getdoc;
  432.         IF (tDoc.GetDocWindow = window) THEN
  433.             FindDoc := tDoc;
  434.         temp := temp.GetNext;
  435.     END;
  436. END;
  437.  
  438. {$S Main}
  439. {-----------------------------------+
  440. |    NumDocs                            |
  441. +-----------------------------------}
  442. FUNCTION TDocumentList.NumDocs:integer;
  443. BEGIN
  444.     NumDocs := fNumDocs;
  445. END;